package org.magicbox.qjunTPO.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.magicbox.qjunTPO.common.lang.Result;
import org.magicbox.qjunTPO.entity.CommentUser;
import org.magicbox.qjunTPO.entity.RequestMe;
import org.magicbox.qjunTPO.service.RequestMeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.websocket.server.PathParam;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * VIEW 前端控制器
 * </p>
 *
 * @author 欢迎添加科技实践队粉丝群：690849711
 * @since 2021-11-16
 */
@RestController
@RequestMapping("/request-me")
public class RequestMeController {
    @Autowired
    RequestMeService requestMeService;
    @RequestMapping(value = "getByUserId",method = RequestMethod.POST)
    public Result getByUserId(@PathParam("id") Integer id ,@PathParam("pageNumber")Integer pageNumber){
        //获取评论和评论者头像和网名
        Page page =new Page(pageNumber,3);
        Map<String,Integer> poemMap = new HashMap<String,Integer>();
        poemMap.put("commentuser",id);
        IPage pageData =requestMeService.page(page,new QueryWrapper<RequestMe>().allEq(poemMap).orderByDesc("comment_create"));

        return Result.success(pageData);
    }
}
